<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<div id="container">
    <p>
    <input v-model="question"/></p>

    <p>{{answer}}</p>

    <img :src="answerImage"/>

</div>

<script src="https://unpkg.com/vue@next"></script>
<script src="https://cdn.jsdelivr.net/npm/axios@0.12.0/dist/axios.min.js"></script>
<script type="text/javascript">

    const demoApp = {
        data(){
            return {
                question: '',
                answer: '',
                answerImage: ''
            }
        },
        mounted(){

        },
        watch:{

            question(newQuestion, oldQuestion){
                if (newQuestion.indexOf('?') > -1){
                    this.getAnswer()
                }
            }
        },
        methods:{
            getAnswer(){

                this.answer = 'Thinnk...'

                axios.get('https://yesno.wtf/api')
                .then(response => {
                    this.answer = response.data.answer
                    this.answerImage = response.data.image
                })
                .catch(error => {
                    this.answer = error
                })
            }

        }

    }

    Vue.createApp(demoApp).mount('#container')
</script>

</body>
</html>
